<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Answer set programming</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Answer_set_programming"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Answer_set_programming rootpage-Answer_set_programming skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Answer set programming</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Not to be confused with <a href="Active_Server_Pages" title="Active Server Pages">Active Server Pages</a>.</div>
<p><b>Answer set programming</b> (<b>ASP</b>) is a form of <a href="Declarative_programming" title="Declarative programming">declarative programming</a> oriented towards difficult (primarily <a href="NP-hard" class="mw-redirect" title="NP-hard">NP-hard</a>) <a href="Search_algorithm" title="Search algorithm">search problems</a>. It is based on the <a href="Stable_model_semantics" title="Stable model semantics">stable model</a> (answer set) semantics of <a href="Logic_programming" title="Logic programming">logic programming</a>. In ASP, search problems are reduced to computing stable models, and <i>answer set solvers</i>—programs for generating stable models—are used to perform search. The computational process employed in the design of many answer set solvers is an enhancement of the <a href="DPLL_algorithm" title="DPLL algorithm">DPLL algorithm</a> and, in principle, it always terminates (unlike <a href="Prolog" title="Prolog">Prolog</a> query evaluation, which may lead to an <a href="Infinite_loop" title="Infinite loop">infinite loop</a>).
</p><p>In a more general sense, ASP includes all applications of answer sets to <a href="Knowledge_representation_and_reasoning" title="Knowledge representation and reasoning">knowledge representation and reasoning</a><sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> and the use of Prolog-style query evaluation for solving problems arising in these applications.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<p>An early example of answer set programming was the <a href="Automated_planning_and_scheduling" title="Automated planning and scheduling">planning</a> method proposed in 1997 by Dimopoulos, Nebel and Köhler.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-WhatIs_4-0" class="reference"><a href="#cite_note-WhatIs-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> Their approach is based on the relationship between plans and stable models.<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
In 1998 Soininen and Niemelä<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
applied what is now known as answer set programming to the problem of <a href="Product_configuration" class="mw-redirect" title="Product configuration">product configuration</a>.<sup id="cite_ref-WhatIs_4-1" class="reference"><a href="#cite_note-WhatIs-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> In 1999, the term "answer set programming" appeared for the first time in a book <i>The Logic Programming Paradigm</i> as the title of a collection of two papers.<sup id="cite_ref-WhatIs_4-2" class="reference"><a href="#cite_note-WhatIs-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> The first of these papers identified the use of answer set solvers for search as a new <a href="Programming_paradigm" title="Programming paradigm">programming paradigm</a>.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> That same year Niemelä also proposed "logic programs with stable model semantics" as a new paradigm.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Answer_set_programming_language_AnsProlog">Answer set programming language AnsProlog</h2></div>
<p><a rel="nofollow" class="external text" href="http://www.tcs.hut.fi/Software/smodels/lparse.ps">Lparse</a> is the name of the program that was originally created as a <a href="Symbol_grounding" class="mw-redirect" title="Symbol grounding">grounding</a> tool (front-end) for the answer set solver <a rel="nofollow" class="external text" href="http://www.tcs.hut.fi/Software/smodels/">smodels</a>. The language that Lparse accepts is now commonly called AnsProlog,<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> short for <i>Answer Set Programming in Logic</i>.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> It is now used in the same way in many other answer set solvers, including <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110717180541/http://assat.cs.ust.hk/">assat</a>, <a rel="nofollow" class="external text" href="https://potassco.org/clasp/">clasp</a>, <a rel="nofollow" class="external text" href="http://www.cs.utexas.edu/users/tag/cmodels/">cmodels</a>, <a rel="nofollow" class="external text" href="http://www.tcs.hut.fi/Software/gnt/">gNt</a>, <a rel="nofollow" class="external text" href="http://www.cs.uni-potsdam.de/nomore/">nomore++</a> and <a rel="nofollow" class="external text" href="http://www.cs.uky.edu/ai/pbmodels/">pbmodels</a>. (<a rel="nofollow" class="external text" href="http://www.dbai.tuwien.ac.at/proj/dlv/">dlv</a> is an exception; the syntax of ASP programs written for dlv is somewhat different.)
</p><p>An AnsProlog program consists of rules of the form
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="o"><</span><span class="s s-Atom">head</span><span class="o">></span> <span class="p">:-</span> <span class="o"><</span><span class="s s-Atom">body</span><span class="o">></span> <span class="p">.</span>
</pre></div>
<p>The symbol <code>:-</code> ("if") is dropped if <code><body></code> is empty; such rules are called <i>facts</i>. The simplest kind of Lparse rules are <a href="Stable_model_semantics#Programs_with_constraints" title="Stable model semantics">rules with constraints</a>.
</p><p>One other useful construct included in this language is <i>choice</i>. For instance, the choice rule
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="p">{</span><span class="s s-Atom">p</span><span class="p">,</span><span class="s s-Atom">q</span><span class="p">,</span><span class="s s-Atom">r</span><span class="p">}.</span>
</pre></div>
<p>says: choose arbitrarily which of the atoms <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle p,q,r}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>p</mi>
<mo>,</mo>
<mi>q</mi>
<mo>,</mo>
<mi>r</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle p,q,r}</annotation>
</semantics>
</math></span><img src="./04bd013a2bae7bf9b04fbf84a70479a2af3bf278.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; margin-left: -0.089ex; width:5.445ex; height:2.009ex;" alt="{\displaystyle p,q,r}" loading="lazy"></span> to include in the stable model. The Lparse program that contains this choice rule and no other rules has 8 stable models—arbitrary subsets of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{p,q,r\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<mi>p</mi>
<mo>,</mo>
<mi>q</mi>
<mo>,</mo>
<mi>r</mi>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{p,q,r\}}</annotation>
</semantics>
</math></span><img src="./cbbe3060fead13d62d162d182719dff8c002e0f2.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:7.68ex; height:2.843ex;" alt="{\displaystyle \{p,q,r\}}" loading="lazy"></span>. The definition of a stable model was generalized to programs with choice rules.<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> Choice rules can be treated also as abbreviations for <a href="Stable_model_semantics#Stable_models_of_a_set_of_propositional_formulas" title="Stable model semantics">propositional formulas under the stable model semantics</a>.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> For instance, the choice rule above can be viewed as shorthand for the conjunction of three "<a href="Excluded_middle" class="mw-redirect" title="Excluded middle">excluded middle</a>" formulas:
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (p\lor \neg p)\land (q\lor \neg q)\land (r\lor \neg r).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo stretchy="false">(</mo>
<mi>p</mi>
<mo>∨<!-- ∨ --></mo>
<mi mathvariant="normal">¬<!-- ¬ --></mi>
<mi>p</mi>
<mo stretchy="false">)</mo>
<mo>∧<!-- ∧ --></mo>
<mo stretchy="false">(</mo>
<mi>q</mi>
<mo>∨<!-- ∨ --></mo>
<mi mathvariant="normal">¬<!-- ¬ --></mi>
<mi>q</mi>
<mo stretchy="false">)</mo>
<mo>∧<!-- ∧ --></mo>
<mo stretchy="false">(</mo>
<mi>r</mi>
<mo>∨<!-- ∨ --></mo>
<mi mathvariant="normal">¬<!-- ¬ --></mi>
<mi>r</mi>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle (p\lor \neg p)\land (q\lor \neg q)\land (r\lor \neg r).}</annotation>
</semantics>
</math></span><img src="./661ce19191229ac0468221f7762c284ef3d23ba7.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:30.214ex; height:2.843ex;" alt="{\displaystyle (p\lor \neg p)\land (q\lor \neg q)\land (r\lor \neg r).}" loading="lazy"></span></dd></dl>
<p>The language of Lparse allows us also to write "constrained" choice rules, such as
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="mi">1</span><span class="p">{</span><span class="s s-Atom">p</span><span class="p">,</span><span class="s s-Atom">q</span><span class="p">,</span><span class="s s-Atom">r</span><span class="p">}</span><span class="mf">2.</span>
</pre></div>
<p>This rule says: choose at least 1 of the atoms <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle p,q,r}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>p</mi>
<mo>,</mo>
<mi>q</mi>
<mo>,</mo>
<mi>r</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle p,q,r}</annotation>
</semantics>
</math></span><img src="./04bd013a2bae7bf9b04fbf84a70479a2af3bf278.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; margin-left: -0.089ex; width:5.445ex; height:2.009ex;" alt="{\displaystyle p,q,r}" loading="lazy"></span>, but not more than 2. The meaning of this rule under the stable model semantics is represented by the <a href="Propositional_formula" title="Propositional formula">propositional formula</a>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (p\lor \neg p)\land (q\lor \neg q)\land (r\lor \neg r)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo stretchy="false">(</mo>
<mi>p</mi>
<mo>∨<!-- ∨ --></mo>
<mi mathvariant="normal">¬<!-- ¬ --></mi>
<mi>p</mi>
<mo stretchy="false">)</mo>
<mo>∧<!-- ∧ --></mo>
<mo stretchy="false">(</mo>
<mi>q</mi>
<mo>∨<!-- ∨ --></mo>
<mi mathvariant="normal">¬<!-- ¬ --></mi>
<mi>q</mi>
<mo stretchy="false">)</mo>
<mo>∧<!-- ∧ --></mo>
<mo stretchy="false">(</mo>
<mi>r</mi>
<mo>∨<!-- ∨ --></mo>
<mi mathvariant="normal">¬<!-- ¬ --></mi>
<mi>r</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle (p\lor \neg p)\land (q\lor \neg q)\land (r\lor \neg r)}</annotation>
</semantics>
</math></span><img src="./d46f52c3039d9a37f77d61d48fa25cfd379b806b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:29.567ex; height:2.843ex;" alt="{\displaystyle (p\lor \neg p)\land (q\lor \neg q)\land (r\lor \neg r)}" loading="lazy"></span></dd></dl>
<dl><dd><dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \land \,(p\lor q\lor r)\land \neg (p\land q\land r).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo>∧<!-- ∧ --></mo>
<mspace width="thinmathspace"></mspace>
<mo stretchy="false">(</mo>
<mi>p</mi>
<mo>∨<!-- ∨ --></mo>
<mi>q</mi>
<mo>∨<!-- ∨ --></mo>
<mi>r</mi>
<mo stretchy="false">)</mo>
<mo>∧<!-- ∧ --></mo>
<mi mathvariant="normal">¬<!-- ¬ --></mi>
<mo stretchy="false">(</mo>
<mi>p</mi>
<mo>∧<!-- ∧ --></mo>
<mi>q</mi>
<mo>∧<!-- ∧ --></mo>
<mi>r</mi>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \land \,(p\lor q\lor r)\land \neg (p\land q\land r).}</annotation>
</semantics>
</math></span><img src="./c39795b3dc4fda937af044259cfb0b0d223d3d74.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:27.241ex; height:2.843ex;" alt="{\displaystyle \land \,(p\lor q\lor r)\land \neg (p\land q\land r).}" loading="lazy"></span></dd></dl></dd></dl>
<p>Cardinality bounds can be used in the body of a rule as well, for instance:
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="p">:-</span> <span class="mi">2</span><span class="p">{</span><span class="s s-Atom">p</span><span class="p">,</span><span class="s s-Atom">q</span><span class="p">,</span><span class="s s-Atom">r</span><span class="p">}.</span>
</pre></div>
<p>Adding this constraint to an Lparse program eliminates the stable models that contain at least 2 of the atoms <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle p,q,r}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>p</mi>
<mo>,</mo>
<mi>q</mi>
<mo>,</mo>
<mi>r</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle p,q,r}</annotation>
</semantics>
</math></span><img src="./04bd013a2bae7bf9b04fbf84a70479a2af3bf278.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; margin-left: -0.089ex; width:5.445ex; height:2.009ex;" alt="{\displaystyle p,q,r}" loading="lazy"></span>. The meaning of this rule can be represented by the propositional formula
</p>
<dl><dd><dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \neg ((p\land q)\lor (p\land r)\lor (q\land r)).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">¬<!-- ¬ --></mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">(</mo>
<mi>p</mi>
<mo>∧<!-- ∧ --></mo>
<mi>q</mi>
<mo stretchy="false">)</mo>
<mo>∨<!-- ∨ --></mo>
<mo stretchy="false">(</mo>
<mi>p</mi>
<mo>∧<!-- ∧ --></mo>
<mi>r</mi>
<mo stretchy="false">)</mo>
<mo>∨<!-- ∨ --></mo>
<mo stretchy="false">(</mo>
<mi>q</mi>
<mo>∧<!-- ∧ --></mo>
<mi>r</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \neg ((p\land q)\lor (p\land r)\lor (q\land r)).}</annotation>
</semantics>
</math></span><img src="./6c44f9904ab55b826ebf942bc9d1112e4ab9032a.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:28.923ex; height:2.843ex;" alt="{\displaystyle \neg ((p\land q)\lor (p\land r)\lor (q\land r)).}" loading="lazy"></span></dd></dl></dd></dl>
<p>Variables (capitalized, as in <a href="Prolog#Data_types" title="Prolog">Prolog</a>) are used in Lparse to abbreviate collections of rules that follow the same pattern, and also to abbreviate collections of atoms within the same rule. For instance, the Lparse program
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">p</span><span class="p">(</span><span class="s s-Atom">a</span><span class="p">).</span> <span class="nf">p</span><span class="p">(</span><span class="s s-Atom">b</span><span class="p">).</span> <span class="nf">p</span><span class="p">(</span><span class="s s-Atom">c</span><span class="p">).</span>
<span class="nf">q</span><span class="p">(</span><span class="nv">X</span><span class="p">)</span> <span class="p">:-</span> <span class="nf">p</span><span class="p">(</span><span class="nv">X</span><span class="p">),</span> <span class="nv">X</span><span class="p">!</span><span class="o">=</span><span class="s s-Atom">a</span><span class="p">.</span>
</pre></div>
<p>has the same meaning as
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">p</span><span class="p">(</span><span class="s s-Atom">a</span><span class="p">).</span> <span class="nf">p</span><span class="p">(</span><span class="s s-Atom">b</span><span class="p">).</span> <span class="nf">p</span><span class="p">(</span><span class="s s-Atom">c</span><span class="p">).</span>
<span class="nf">q</span><span class="p">(</span><span class="s s-Atom">b</span><span class="p">).</span> <span class="nf">q</span><span class="p">(</span><span class="s s-Atom">c</span><span class="p">).</span>
</pre></div>
<p>The program
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">p</span><span class="p">(</span><span class="s s-Atom">a</span><span class="p">).</span> <span class="nf">p</span><span class="p">(</span><span class="s s-Atom">b</span><span class="p">).</span> <span class="nf">p</span><span class="p">(</span><span class="s s-Atom">c</span><span class="p">).</span>
<span class="p">{</span><span class="nf">q</span><span class="p">(</span><span class="nv">X</span><span class="p">):-</span><span class="nf">p</span><span class="p">(</span><span class="nv">X</span><span class="p">)}</span><span class="mf">2.</span>
</pre></div>
<p>is shorthand for
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">p</span><span class="p">(</span><span class="s s-Atom">a</span><span class="p">).</span> <span class="nf">p</span><span class="p">(</span><span class="s s-Atom">b</span><span class="p">).</span> <span class="nf">p</span><span class="p">(</span><span class="s s-Atom">c</span><span class="p">).</span>
<span class="p">{</span><span class="nf">q</span><span class="p">(</span><span class="s s-Atom">a</span><span class="p">),</span> <span class="nf">q</span><span class="p">(</span><span class="s s-Atom">b</span><span class="p">),</span> <span class="nf">q</span><span class="p">(</span><span class="s s-Atom">c</span><span class="p">)}</span><span class="mf">2.</span>
</pre></div>
<p>A <i>range</i> is of the form:
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="p">(</span><span class="s s-Atom">start</span><span class="p">..</span><span class="s s-Atom">end</span><span class="p">)</span>
</pre></div>
<p>where start and end are constant-valued arithmetic expressions. A range is a notational shortcut that is mainly used to define numerical domains in a compatible way. For example, the fact
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">a</span><span class="p">(</span><span class="mf">1..3</span><span class="p">).</span>
</pre></div>
<p>is a shortcut for
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">a</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span> <span class="nf">a</span><span class="p">(</span><span class="mi">2</span><span class="p">).</span> <span class="nf">a</span><span class="p">(</span><span class="mi">3</span><span class="p">).</span>
</pre></div>
<p>Ranges can also be used in rule bodies with the same semantics.
</p><p>A <i>conditional literal</i> is of the form:
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">p</span><span class="p">(</span><span class="nv">X</span><span class="p">)</span><span class="s s-Atom">:</span><span class="nf">q</span><span class="p">(</span><span class="nv">X</span><span class="p">)</span>
</pre></div>
<p>If the extension of <code>q</code> is <code>{q(a1), q(a2), ..., q(aN)}</code>, the above condition is semantically equivalent to writing <code>{p(a1), p(a2), ..., p(aN)}</code> in the place of the condition. For example,
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">q</span><span class="p">(</span><span class="mf">1..2</span><span class="p">).</span>
<span class="nf">a</span> <span class="o">:-</span> <span class="mi">1</span> <span class="p">{</span><span class="nf">p</span><span class="p">(</span><span class="nv">X</span><span class="p">)</span><span class="s s-Atom">:</span><span class="nf">q</span><span class="p">(</span><span class="nv">X</span><span class="p">)}.</span>
</pre></div>
<p>is a shorthand for
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">q</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span> <span class="nf">q</span><span class="p">(</span><span class="mi">2</span><span class="p">).</span>
<span class="nf">a</span> <span class="o">:-</span> <span class="mi">1</span> <span class="p">{</span><span class="nf">p</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="nf">p</span><span class="p">(</span><span class="mi">2</span><span class="p">)}.</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Generating_stable_models">Generating stable models</h2></div>
<p>To find a stable model of the Lparse program stored in file <code>${filename}</code> we use the command
</p>
<div class="mw-highlight mw-highlight-lang-console mw-content-ltr" dir="ltr"><pre><span class="gp">% </span>lparse<span class="w"> </span><span class="si">${</span><span class="nv">filename</span><span class="si">}</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>smodels
</pre></div>
<p>Option 0 instructs smodels to find <i>all</i> stable models of the program. For instance, if file <code>test</code> contains the rules
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="mi">1</span><span class="p">{</span><span class="s s-Atom">p</span><span class="p">,</span><span class="s s-Atom">q</span><span class="p">,</span><span class="s s-Atom">r</span><span class="p">}</span><span class="mf">2.</span>
<span class="nf">s</span> <span class="o">:-</span> <span class="o">not</span> <span class="s s-Atom">p</span><span class="p">.</span>
</pre></div>
<p>then the command produces the output
</p>
<div class="mw-highlight mw-highlight-lang-console mw-content-ltr" dir="ltr"><pre><span class="gp">% </span>lparse<span class="w"> </span><span class="nb">test</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>smodels<span class="w"> </span><span class="m">0</span>
<span class="go">Answer: 1</span>
<span class="go">Stable Model: q p </span>
<span class="go">Answer: 2</span>
<span class="go">Stable Model: p </span>
<span class="go">Answer: 3</span>
<span class="go">Stable Model: r p </span>
<span class="go">Answer: 4</span>
<span class="go">Stable Model: q s </span>
<span class="go">Answer: 5</span>
<span class="go">Stable Model: r s </span>
<span class="go">Answer: 6</span>
<span class="go">Stable Model: r q s</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Examples_of_ASP_programs">Examples of ASP programs</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Graph_coloring">Graph coloring</h3></div>
<p>An <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>n</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle n}</annotation>
</semantics>
</math></span><img src="./a601995d55609f2d9f5e233e36fbe9ea26011b3b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.395ex; height:1.676ex;" alt="{\displaystyle n}" loading="lazy"></span>-<a href="Graph_coloring" title="Graph coloring">coloring</a> of a <a href="Graph_(discrete_mathematics)" title="Graph (discrete mathematics)">graph</a> <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle G=\left\langle V,E\right\rangle }">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>G</mi>
<mo>=</mo>
<mrow>
<mo>⟨</mo>
<mrow>
<mi>V</mi>
<mo>,</mo>
<mi>E</mi>
</mrow>
<mo>⟩</mo>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle G=\left\langle V,E\right\rangle }</annotation>
</semantics>
</math></span><img src="./369bc1a682c9c621d2d5fa33c6ad7c2b46c65063.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:11.331ex; height:2.843ex;" alt="{\displaystyle G=\left\langle V,E\right\rangle }" loading="lazy"></span> is a function <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathrm {color} :V\to \{1,\dots ,n\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="normal">c</mi>
<mi mathvariant="normal">o</mi>
<mi mathvariant="normal">l</mi>
<mi mathvariant="normal">o</mi>
<mi mathvariant="normal">r</mi>
</mrow>
<mo>:</mo>
<mi>V</mi>
<mo stretchy="false">→<!-- → --></mo>
<mo fence="false" stretchy="false">{</mo>
<mn>1</mn>
<mo>,</mo>
<mo>…<!-- … --></mo>
<mo>,</mo>
<mi>n</mi>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \mathrm {color} :V\to \{1,\dots ,n\}}</annotation>
</semantics>
</math></span><img src="./780dacd22065f58d76823b36655e188fd2f64a11.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:22.315ex; height:2.843ex;" alt="{\displaystyle \mathrm {color} :V\to \{1,\dots ,n\}}" loading="lazy"></span> such that <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathrm {color} (x)\neq \mathrm {color} (y)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="normal">c</mi>
<mi mathvariant="normal">o</mi>
<mi mathvariant="normal">l</mi>
<mi mathvariant="normal">o</mi>
<mi mathvariant="normal">r</mi>
</mrow>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
<mo>≠<!-- ≠ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="normal">c</mi>
<mi mathvariant="normal">o</mi>
<mi mathvariant="normal">l</mi>
<mi mathvariant="normal">o</mi>
<mi mathvariant="normal">r</mi>
</mrow>
<mo stretchy="false">(</mo>
<mi>y</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \mathrm {color} (x)\neq \mathrm {color} (y)}</annotation>
</semantics>
</math></span><img src="./9a5d680a1d1f976818395974070a7ada8df70170.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:19.034ex; height:2.843ex;" alt="{\displaystyle \mathrm {color} (x)\neq \mathrm {color} (y)}" loading="lazy"></span> for every pair of adjacent vertices <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle (x,y)\in E}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo>,</mo>
<mi>y</mi>
<mo stretchy="false">)</mo>
<mo>∈<!-- ∈ --></mo>
<mi>E</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle (x,y)\in E}</annotation>
</semantics>
</math></span><img src="./9ae449747f6f0429c02e36830b8a2ff94ac3dc77.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:9.945ex; height:2.843ex;" alt="{\displaystyle (x,y)\in E}" loading="lazy"></span>. We would like to use ASP to find an <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>n</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle n}</annotation>
</semantics>
</math></span><img src="./a601995d55609f2d9f5e233e36fbe9ea26011b3b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.395ex; height:1.676ex;" alt="{\displaystyle n}" loading="lazy"></span>-coloring of a given graph (or determine that it does not exist).
</p><p>This can be accomplished using the following Lparse program:
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span class="nf">c</span><span class="p">(</span><span class="mf">1.</span><span class="p">.</span><span class="s s-Atom">n</span><span class="p">).</span>
<span class="mi">1</span> <span class="p">{</span><span class="nf">color</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">I</span><span class="p">)</span> <span class="s s-Atom">:</span> <span class="nf">c</span><span class="p">(</span><span class="nv">I</span><span class="p">)}</span> <span class="mi">1</span> <span class="p">:-</span> <span class="nf">v</span><span class="p">(</span><span class="nv">X</span><span class="p">).</span>
<span class="p">:-</span> <span class="nf">color</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">I</span><span class="p">),</span> <span class="nf">color</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span><span class="nv">I</span><span class="p">),</span> <span class="nf">e</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">),</span> <span class="nf">c</span><span class="p">(</span><span class="nv">I</span><span class="p">).</span>
</pre></div>
<p>Line 1 defines the numbers <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 1,\dots ,n}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>1</mn>
<mo>,</mo>
<mo>…<!-- … --></mo>
<mo>,</mo>
<mi>n</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 1,\dots ,n}</annotation>
</semantics>
</math></span><img src="./3183c8ced500768421aa5039ac010066d8122ae3.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:7.735ex; height:2.509ex;" alt="{\displaystyle 1,\dots ,n}" loading="lazy"></span> to be colors. According to the choice rule in Line 2, a unique color <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle i}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>i</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle i}</annotation>
</semantics>
</math></span><img src="./add78d8608ad86e54951b8c8bd6c8d8416533d20.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:0.802ex; height:2.176ex;" alt="{\displaystyle i}" loading="lazy"></span> should be assigned to each vertex <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle x}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>x</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle x}</annotation>
</semantics>
</math></span><img src="./87f9e315fd7e2ba406057a97300593c4802b53e4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle x}" loading="lazy"></span>. The constraint in Line 3 prohibits assigning the same color to vertices <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle x}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>x</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle x}</annotation>
</semantics>
</math></span><img src="./87f9e315fd7e2ba406057a97300593c4802b53e4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle x}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle y}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>y</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle y}</annotation>
</semantics>
</math></span><img src="./b8a6208ec717213d4317e666f1ae872e00620a0d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:1.155ex; height:2.009ex;" alt="{\displaystyle y}" loading="lazy"></span> if there is an edge connecting them.
</p><p>If we combine this file with a definition of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle G}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>G</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle G}</annotation>
</semantics>
</math></span><img src="./f5f3c8921a3b352de45446a6789b104458c9f90b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.827ex; height:2.176ex;" alt="{\displaystyle G}" loading="lazy"></span>, such as
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="nf">v</span><span class="p">(</span><span class="mf">1..100</span><span class="p">).</span> <span class="c1">% 1,...,100 are vertices</span>
<span class="nf">e</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">55</span><span class="p">).</span> <span class="c1">% there is an edge from 1 to 55</span>
<span class="p">.</span> <span class="p">.</span> <span class="p">.</span>
</pre></div>
<p>and run smodels on it, with the numeric value of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>n</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle n}</annotation>
</semantics>
</math></span><img src="./a601995d55609f2d9f5e233e36fbe9ea26011b3b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.395ex; height:1.676ex;" alt="{\displaystyle n}" loading="lazy"></span> specified on the command line, then the atoms of the form <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathrm {color} (\dots ,\dots )}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="normal">c</mi>
<mi mathvariant="normal">o</mi>
<mi mathvariant="normal">l</mi>
<mi mathvariant="normal">o</mi>
<mi mathvariant="normal">r</mi>
</mrow>
<mo stretchy="false">(</mo>
<mo>…<!-- … --></mo>
<mo>,</mo>
<mo>…<!-- … --></mo>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \mathrm {color} (\dots ,\dots )}</annotation>
</semantics>
</math></span><img src="./691f4ad05a10753f790b27857fe3856f473bc26d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.593ex; height:2.843ex;" alt="{\displaystyle \mathrm {color} (\dots ,\dots )}" loading="lazy"></span> in the output of smodels will represent an <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>n</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle n}</annotation>
</semantics>
</math></span><img src="./a601995d55609f2d9f5e233e36fbe9ea26011b3b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.395ex; height:1.676ex;" alt="{\displaystyle n}" loading="lazy"></span>-coloring of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle G}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>G</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle G}</annotation>
</semantics>
</math></span><img src="./f5f3c8921a3b352de45446a6789b104458c9f90b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.827ex; height:2.176ex;" alt="{\displaystyle G}" loading="lazy"></span>.
</p><p>The program in this example illustrates the "generate-and-test" organization that is often found in simple ASP programs. The choice rule describes a set of "potential solutions"—a simple superset of the set of solutions to the given search problem. It is followed by a constraint, which eliminates all potential solutions that are not acceptable. However, the search process employed by smodels and other answer set solvers is not based on <a href="Trial_and_error" title="Trial and error">trial and error</a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Large_clique">Large clique</h3></div>
<p>A <a href="Clique_(graph_theory)" title="Clique (graph theory)">clique</a> in a graph is a set of pairwise adjacent vertices. The following Lparse program finds a clique of size <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \geq n}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo>≥<!-- ≥ --></mo>
<mi>n</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \geq n}</annotation>
</semantics>
</math></span><img src="./df9b00b0cd97fbcbca5db6958760835fbcc55ebd.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:3.848ex; height:2.176ex;" alt="{\displaystyle \geq n}" loading="lazy"></span> in a given directed graph, or determines that it does not exist:
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span class="s s-Atom">n</span> <span class="p">{</span><span class="nf">in</span><span class="p">(</span><span class="nv">X</span><span class="p">)</span> <span class="s s-Atom">:</span> <span class="nf">v</span><span class="p">(</span><span class="nv">X</span><span class="p">)}.</span>
<span class="p">:-</span> <span class="nf">in</span><span class="p">(</span><span class="nv">X</span><span class="p">),</span> <span class="nf">in</span><span class="p">(</span><span class="nv">Y</span><span class="p">),</span> <span class="nv">X</span><span class="p">!</span><span class="o">=</span><span class="nv">Y</span><span class="p">,</span> <span class="o">not</span> <span class="nf">e</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">).</span>
</pre></div>
<p>This is another example of the generate-and-test organization. The choice rule in Line 1 "generates" all sets consisting of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \geq n}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo>≥<!-- ≥ --></mo>
<mi>n</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \geq n}</annotation>
</semantics>
</math></span><img src="./df9b00b0cd97fbcbca5db6958760835fbcc55ebd.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:3.848ex; height:2.176ex;" alt="{\displaystyle \geq n}" loading="lazy"></span> vertices. The constraint in Line 2 "weeds out" the sets that are not cliques.
</p>
<div class="mw-heading mw-heading3"><h3 id="Hamiltonian_cycle">Hamiltonian cycle</h3></div>
<p>A <a href="Hamiltonian_cycle" class="mw-redirect" title="Hamiltonian cycle">Hamiltonian cycle</a> in a <a href="Directed_graph" title="Directed graph">directed graph</a> is a <a href="Path_(graph_theory)" title="Path (graph theory)">cycle</a> that passes through each vertex of the graph exactly once. The following Lparse program can be used to find a Hamiltonian cycle in a given directed graph if it exists; we assume that 0 is one of the vertices.
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr mw-highlight-lines" dir="ltr"><pre><span class="p">{</span><span class="nf">in</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">)}</span> <span class="p">:-</span> <span class="nf">e</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">).</span>
<span class="p">:-</span> <span class="mi">2</span> <span class="p">{</span><span class="nf">in</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">)</span> <span class="s s-Atom">:</span> <span class="nf">e</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">)},</span> <span class="nf">v</span><span class="p">(</span><span class="nv">X</span><span class="p">).</span>
<span class="p">:-</span> <span class="mi">2</span> <span class="p">{</span><span class="nf">in</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">)</span> <span class="s s-Atom">:</span> <span class="nf">e</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">)},</span> <span class="nf">v</span><span class="p">(</span><span class="nv">Y</span><span class="p">).</span>
<span class="nf">r</span><span class="p">(</span><span class="nv">X</span><span class="p">)</span> <span class="p">:-</span> <span class="nf">in</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nv">X</span><span class="p">),</span> <span class="nf">v</span><span class="p">(</span><span class="nv">X</span><span class="p">).</span>
<span class="nf">r</span><span class="p">(</span><span class="nv">Y</span><span class="p">)</span> <span class="p">:-</span> <span class="nf">r</span><span class="p">(</span><span class="nv">X</span><span class="p">),</span> <span class="nf">in</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">),</span> <span class="nf">e</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span><span class="nv">Y</span><span class="p">).</span>
<span class="p">:-</span> <span class="o">not</span> <span class="nf">r</span><span class="p">(</span><span class="nv">X</span><span class="p">),</span> <span class="nf">v</span><span class="p">(</span><span class="nv">X</span><span class="p">).</span>
</pre></div>
<p>The choice rule in Line 1 "generates" all subsets of the set of edges. The three constraints "weed out" the subsets that are not Hamiltonian cycles. The last of them uses the auxiliary predicate <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r(x)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>r</mi>
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r(x)}</annotation>
</semantics>
</math></span><img src="./0d457e88abd861f46ede37d27c4669c747367109.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:4.188ex; height:2.843ex;" alt="{\displaystyle r(x)}" loading="lazy"></span> ("<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle x}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>x</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle x}</annotation>
</semantics>
</math></span><img src="./87f9e315fd7e2ba406057a97300593c4802b53e4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.33ex; height:1.676ex;" alt="{\displaystyle x}" loading="lazy"></span> is reachable from 0") to prohibit the vertices that do not satisfy this condition. This predicate is defined recursively in Lines 6 and 7.
</p><p>This program is an example of the more general "generate, define and test" organization: it includes the definition of an auxiliary predicate that helps us eliminate all "bad" potential solutions.
</p>
<div class="mw-heading mw-heading3"><h3 id="Dependency_parsing">Dependency parsing</h3></div>
<p>In <a href="Natural_language_processing" title="Natural language processing">natural language processing</a>, <a href="Parsing" title="Parsing">dependency-based parsing</a> can be formulated as an ASP problem.<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup>
The following code parses the Latin sentence "Puella pulchra in villa linguam latinam discit", "the pretty girl is learning Latin in the villa".
The syntax tree is expressed by the <i>arc</i> predicates which represent the dependencies between the words of the sentence.
The computed structure is a linearly ordered rooted tree.
</p>
<div class="mw-highlight mw-highlight-lang-prolog mw-content-ltr" dir="ltr"><pre><span class="c1">% ********** input sentence **********</span>
<span class="nf">word</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s s-Atom">puella</span><span class="p">).</span> <span class="nf">word</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s s-Atom">pulchra</span><span class="p">).</span> <span class="nf">word</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s s-Atom">in</span><span class="p">).</span> <span class="nf">word</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="s s-Atom">villa</span><span class="p">).</span> <span class="nf">word</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="s s-Atom">linguam</span><span class="p">).</span> <span class="nf">word</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span> <span class="s s-Atom">latinam</span><span class="p">).</span> <span class="nf">word</span><span class="p">(</span><span class="mi">7</span><span class="p">,</span> <span class="s s-Atom">discit</span><span class="p">).</span>
<span class="c1">% ********** lexicon **********</span>
<span class="mi">1</span><span class="p">{</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">pulcher</span><span class="p">,</span> <span class="s s-Atom">a</span><span class="p">,</span> <span class="s s-Atom">fem</span><span class="p">,</span> <span class="s s-Atom">nom</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">));</span>
<span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">pulcher</span><span class="p">,</span> <span class="s s-Atom">a</span><span class="p">,</span> <span class="s s-Atom">fem</span><span class="p">,</span> <span class="s s-Atom">abl</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">))</span> <span class="p">}</span><span class="mi">1</span> <span class="p">:-</span> <span class="nf">word</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="s s-Atom">pulchra</span><span class="p">).</span>
<span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">latinus</span><span class="p">,</span> <span class="s s-Atom">a</span><span class="p">,</span> <span class="s s-Atom">fem</span><span class="p">,</span> <span class="s s-Atom">acc</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">))</span> <span class="p">:-</span> <span class="nf">word</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="s s-Atom">latinam</span><span class="p">).</span>
<span class="mi">1</span><span class="p">{</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">puella</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="s s-Atom">fem</span><span class="p">,</span> <span class="s s-Atom">nom</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">));</span>
<span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">puella</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="s s-Atom">fem</span><span class="p">,</span> <span class="s s-Atom">abl</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">))</span> <span class="p">}</span><span class="mi">1</span> <span class="p">:-</span> <span class="nf">word</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="s s-Atom">puella</span><span class="p">).</span>
<span class="mi">1</span><span class="p">{</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">villa</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="s s-Atom">fem</span><span class="p">,</span> <span class="s s-Atom">nom</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">));</span>
<span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">villa</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="s s-Atom">fem</span><span class="p">,</span> <span class="s s-Atom">abl</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">))</span> <span class="p">}</span><span class="mi">1</span> <span class="p">:-</span> <span class="nf">word</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="s s-Atom">villa</span><span class="p">).</span>
<span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">linguam</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="s s-Atom">fem</span><span class="p">,</span> <span class="s s-Atom">acc</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">))</span> <span class="p">:-</span> <span class="nf">word</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="s s-Atom">linguam</span><span class="p">).</span>
<span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">discere</span><span class="p">,</span> <span class="s s-Atom">v</span><span class="p">,</span> <span class="s s-Atom">pres</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">))</span> <span class="p">:-</span> <span class="nf">word</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="s s-Atom">discit</span><span class="p">).</span>
<span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="s s-Atom">in</span><span class="p">,</span> <span class="s s-Atom">p</span><span class="p">))</span> <span class="p">:-</span> <span class="nf">word</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="s s-Atom">in</span><span class="p">).</span>
<span class="c1">% ********** syntactic rules **********</span>
<span class="mi">0</span><span class="p">{</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="s s-Atom">subj</span><span class="p">)</span> <span class="p">}</span><span class="mi">1</span> <span class="p">:-</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">v</span><span class="p">,</span> <span class="k">_</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">)),</span> <span class="nf">node</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="k">_</span><span class="p">,</span> <span class="s s-Atom">nom</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">)).</span>
<span class="mi">0</span><span class="p">{</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="s s-Atom">dobj</span><span class="p">)</span> <span class="p">}</span><span class="mi">1</span> <span class="p">:-</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">v</span><span class="p">,</span> <span class="k">_</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">)),</span> <span class="nf">node</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="k">_</span><span class="p">,</span> <span class="s s-Atom">acc</span><span class="p">,</span> <span class="s s-Atom">sg</span><span class="p">)).</span>
<span class="mi">0</span><span class="p">{</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="s s-Atom">attr</span><span class="p">)</span> <span class="p">}</span><span class="mi">1</span> <span class="p">:-</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="nv">Gender</span><span class="p">,</span> <span class="nv">Case</span><span class="p">,</span> <span class="nv">Number</span><span class="p">)),</span> <span class="nf">node</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">a</span><span class="p">,</span> <span class="nv">Gender</span><span class="p">,</span> <span class="nv">Case</span><span class="p">,</span> <span class="nv">Number</span><span class="p">)).</span>
<span class="mi">0</span><span class="p">{</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="s s-Atom">prep</span><span class="p">)</span> <span class="p">}</span><span class="mi">1</span> <span class="p">:-</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">p</span><span class="p">)),</span> <span class="nf">node</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">n</span><span class="p">,</span> <span class="k">_</span><span class="p">,</span> <span class="s s-Atom">abl</span><span class="p">,</span> <span class="k">_</span><span class="p">)),</span> <span class="nv">X</span> <span class="o"><</span> <span class="nv">Y</span><span class="p">.</span>
<span class="mi">0</span><span class="p">{</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="s s-Atom">adv</span><span class="p">)</span> <span class="p">}</span><span class="mi">1</span> <span class="p">:-</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">v</span><span class="p">,</span> <span class="k">_</span><span class="p">,</span> <span class="k">_</span><span class="p">,</span> <span class="k">_</span><span class="p">)),</span> <span class="nf">node</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span> <span class="nf">attr</span><span class="p">(</span><span class="k">_</span><span class="p">,</span> <span class="s s-Atom">p</span><span class="p">)),</span> <span class="o">not</span> <span class="nf">leaf</span><span class="p">(</span><span class="nv">Y</span><span class="p">).</span>
<span class="c1">% ********** guaranteeing the treeness of the graph **********</span>
<span class="mi">1</span><span class="p">{</span> <span class="nf">root</span><span class="p">(</span><span class="nv">X</span><span class="p">)</span><span class="s s-Atom">:</span><span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="k">_</span><span class="p">)</span> <span class="p">}</span><span class="mf">1.</span>
<span class="p">:-</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Z</span><span class="p">,</span> <span class="k">_</span><span class="p">),</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span> <span class="nv">Z</span><span class="p">,</span> <span class="k">_</span><span class="p">),</span> <span class="nv">X</span> <span class="p">!</span><span class="o">=</span> <span class="nv">Y</span><span class="p">.</span>
<span class="p">:-</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="nv">L1</span><span class="p">),</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="nv">L2</span><span class="p">),</span> <span class="nv">L1</span> <span class="p">!</span><span class="o">=</span> <span class="nv">L2</span><span class="p">.</span>
<span class="nf">path</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">)</span> <span class="p">:-</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="k">_</span><span class="p">).</span>
<span class="nf">path</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Z</span><span class="p">)</span> <span class="p">:-</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">,</span> <span class="k">_</span><span class="p">),</span> <span class="nf">path</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span> <span class="nv">Z</span><span class="p">).</span>
<span class="p">:-</span> <span class="nf">path</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">X</span><span class="p">).</span>
<span class="p">:-</span> <span class="nf">root</span><span class="p">(</span><span class="nv">X</span><span class="p">),</span> <span class="nf">node</span><span class="p">(</span><span class="nv">Y</span><span class="p">,</span> <span class="k">_</span><span class="p">),</span> <span class="nv">X</span> <span class="p">!</span><span class="o">=</span> <span class="nv">Y</span><span class="p">,</span> <span class="o">not</span> <span class="nf">path</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="nv">Y</span><span class="p">).</span>
<span class="nf">leaf</span><span class="p">(</span><span class="nv">X</span><span class="p">)</span> <span class="p">:-</span> <span class="nf">node</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="k">_</span><span class="p">),</span> <span class="o">not</span> <span class="nf">arc</span><span class="p">(</span><span class="nv">X</span><span class="p">,</span> <span class="k">_</span><span class="p">,</span> <span class="k">_</span><span class="p">).</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="Language_standardization_and_ASP_Competition">Language standardization and ASP Competition</h2></div>
<p>The ASP standardization working group produced a standard language specification, called ASP-Core-2,<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> towards which recent ASP systems are converging. ASP-Core-2 is the reference language for the Answer Set Programming Competition, in which ASP solvers are periodically benchmarked over a number of reference problems.
</p>
<div class="mw-heading mw-heading2"><h2 id="Comparison_of_implementations">Comparison of implementations</h2></div>
<p>Early systems, such as smodels, used <a href="Backtracking" title="Backtracking">backtracking</a> to find solutions. As the theory and practice of <a href="Boolean_SAT_solver" class="mw-redirect" title="Boolean SAT solver">Boolean SAT solvers</a> evolved, a number of ASP solvers were built on top of SAT solvers, including ASSAT and Cmodels. These converted ASP formula into SAT propositions, applied the SAT solver, and then converted the solutions back to ASP form. More recent systems, such as Clasp, use a hybrid approach, using conflict-driven algorithms inspired by SAT, without fully converting into a Boolean-logic form. These approaches allow for significant improvements of performance, often by an order of magnitude, over earlier backtracking algorithms.
</p><p>The <a rel="nofollow" class="external text" href="https://potassco.org/">Potassco</a> project acts as an umbrella for many of the systems below, including <i>clasp</i>, grounding systems (<i>gringo</i>), incremental systems (<i>iclingo</i>), constraint solvers (<i>clingcon</i>), <a href="Action_language" title="Action language">action language</a> to ASP compilers (<i>coala</i>), distributed <a href="Message_Passing_Interface" title="Message Passing Interface">Message Passing Interface</a> implementations (<i>claspar</i>), and many others.
</p><p>Most systems support variables, but only indirectly, by forcing grounding, by using a grounding system such as <i>Lparse</i> or <i>gringo</i> as a front end. The need for grounding can cause a combinatorial explosion of clauses; thus, systems that perform on-the-fly grounding might have an advantage.<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup>
</p><p>Query-driven implementations of answer set programming, such as the Galliwasp system<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup> and s(CASP)<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup> avoid grounding altogether by using a combination of <a href="Resolution_(logic)" title="Resolution (logic)">resolution</a> and <a href="Coinduction" title="Coinduction">coinduction</a>.
</p>
<table class="wikitable">
<tbody><tr>
<th colspan="3">Platform
</th>
<th colspan="5">Features
</th>
<th colspan="1">Mechanics
</th></tr>
<tr>
<th style="background:#ffdead;">Name
</th>
<th style="background:#ffdead;">OS
</th>
<th style="background:#ffdead;">Licence
</th>
<th style="background:#ffdead;">Variables
</th>
<th style="background:#ffdead;">Function symbols
</th>
<th style="background:#ffdead;">Explicit sets
</th>
<th style="background:#ffdead;">Explicit lists
</th>
<th style="background:#ffdead;">Disjunctive (choice rules) support
</th>
<th>
</th></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.info.univ-angers.fr/pub/claire/asperix/">ASPeRiX</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20161108121331/http://www.info.univ-angers.fr/pub/claire/asperix/">Archived</a> 2016-11-08 at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>
</td>
<td><a href="GPL" class="mw-redirect" title="GPL">GPL</a>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td>on-the-fly grounding
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20110717180541/http://assat.cs.ust.hk/">ASSAT</a>
</td>
<td><a href="Solaris_(operating_system)" class="mw-redirect" title="Solaris (operating system)">Solaris</a>
</td>
<td><a href="Freeware" title="Freeware">Freeware</a>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>SAT-solver based
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.cs.uni-potsdam.de/clasp/">Clasp Answer Set Solver</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>, <a href="MacOS" title="MacOS">macOS</a>, <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a>
</td>
<td><a href="MIT_License" title="MIT License">MIT License</a>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes, in Clingo
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td>incremental, SAT-solver inspired (nogood, conflict-driven)
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.cs.utexas.edu/users/tag/cmodels/">Cmodels</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>, <a href="Solaris_(operating_system)" class="mw-redirect" title="Solaris (operating system)">Solaris</a>
</td>
<td><a href="GPL" class="mw-redirect" title="GPL">GPL</a>
</td>
<td style="background: #FFD; color:black; vertical-align: middle; text-align: center;" class="partial table-partial">Requires grounding
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td>incremental, SAT-solver inspired (nogood, conflict-driven)
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="https://github.com/MatthiasNickles/diff-SAT/">diff-SAT</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>, <a href="MacOS" title="MacOS">macOS</a>, <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> (<a href="Java_virtual_machine" title="Java virtual machine">Java virtual machine</a>)
</td>
<td><a href="MIT_License" title="MIT License">MIT License</a>
</td>
<td style="background: #FFD; color:black; vertical-align: middle; text-align: center;" class="partial table-partial">Requires grounding
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td>SAT-solver inspired (nogood, conflict-driven). Supports solving probabilistic problems and answer set sampling
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a href="DLV" class="mw-redirect" title="DLV">DLV</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>, <a href="MacOS" title="MacOS">macOS</a>, <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a><sup id="cite_ref-dlvsystem.com_18-0" class="reference"><a href="#cite_note-dlvsystem.com-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</td>
<td>free for academic and non-commercial educational use, and for non-profit organizations<sup id="cite_ref-dlvsystem.com_18-1" class="reference"><a href="#cite_note-dlvsystem.com-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td>not Lparse compatible
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.mat.unical.it/dlv-complex/">DLV-Complex</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>, <a href="MacOS" title="MacOS">macOS</a>, <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a>
</td>
<td><a href="GPL" class="mw-redirect" title="GPL">GPL</a>
</td>
<td>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td>built on top of <a href="DLV" class="mw-redirect" title="DLV">DLV</a> — not Lparse compatible
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.tcs.hut.fi/Software/gnt/">GnT</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>
</td>
<td><a href="GPL" class="mw-redirect" title="GPL">GPL</a>
</td>
<td style="background: #FFD; color:black; vertical-align: middle; text-align: center;" class="partial table-partial">Requires grounding
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes
</td>
<td>built on top of smodels
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.cs.uni-potsdam.de/nomore/">nomore++</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>
</td>
<td><a href="GPL" class="mw-redirect" title="GPL">GPL</a>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>combined literal+rule-based
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.cs.uni-potsdam.de/platypus/">Platypus</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>, <a href="Solaris_(operating_system)" class="mw-redirect" title="Solaris (operating system)">Solaris</a>, <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a>
</td>
<td><a href="GPL" class="mw-redirect" title="GPL">GPL</a>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>distributed, multi-threaded nomore++, smodels
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.cs.uky.edu/ai/pbmodels/">Pbmodels</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>
</td>
<td>?
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>pseudo-boolean solver based
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.tcs.hut.fi/Software/smodels/">Smodels</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>, <a href="MacOS" title="MacOS">macOS</a>, <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a>
</td>
<td><a href="GPL" class="mw-redirect" title="GPL">GPL</a>
</td>
<td style="background: #FFD; color:black; vertical-align: middle; text-align: center;" class="partial table-partial">Requires grounding
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No
</td>
<td>
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.nku.edu/~wardj1/Research/smodels_cc.html">Smodels-cc</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20151115171208/http://www.nku.edu/~wardj1/Research/smodels_cc.html">Archived</a> 2015-11-15 at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>
</td>
<td>?
</td>
<td style="background: #FFD; color:black; vertical-align: middle; text-align: center;" class="partial table-partial">Requires grounding
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>SAT-solver based; smodels w/conflict clauses
</td></tr>
<tr>
<td style="background: #ececec; color: black; font-weight: bold; vertical-align: middle; text-align: left;" class="table-rh"><a rel="nofollow" class="external text" href="http://www.cs.utexas.edu/users/tag/sup/">Sup</a>
</td>
<td><a href="Linux" title="Linux">Linux</a>
</td>
<td>?
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>SAT-solver based
</td></tr></tbody></table>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Default_logic" title="Default logic">Default logic</a></li>
<li><a href="Logic_programming" title="Logic programming">Logic programming</a></li>
<li><a href="Non-monotonic_logic" title="Non-monotonic logic">Non-monotonic logic</a></li>
<li><a href="Prolog" title="Prolog">Prolog</a></li>
<li><a href="Stable_model_semantics" title="Stable model semantics">Stable model semantics</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFBaral2003" class="citation book cs1">Baral, Chitta (2003). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/knowledgereprese00bara"><i>Knowledge Representation, Reasoning and Declarative Problem Solving</i></a></span>. Cambridge University Press. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-521-81802-5</bdi>.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite id="CITEREFGelfond2008" class="citation book cs1">Gelfond, Michael (2008). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=xwBDylHhJhYC&pg=PA285">"Answer sets"</a>. In van Harmelen, Frank; Lifschitz, Vladimir; Porter, Bruce (eds.). <i>Handbook of Knowledge Representation</i>. Elsevier. pp. <span class="nowrap">285–</span>316. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-08-055702-1</bdi>.</cite> <a rel="nofollow" class="external text" href="http://www.depts.ttu.edu/cs/research/krlab/pdfs/papers/gel07b.pdf">as PDF</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160303231241/http://www.depts.ttu.edu/cs/research/krlab/pdfs/papers/gel07b.pdf">Archived</a> 2016-03-03 at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text">
<cite id="CITEREFDimopoulosNebelKöhler1997" class="citation book cs1">Dimopoulos, Y.; <a href="Bernhard_Nebel" title="Bernhard Nebel">Nebel, B.</a>; Köhler, J. (1997). "Encoding planning problems in non-monotonic logic programs". In Steel, Sam; Alami, Rachid (eds.). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=QSBoQgAACAAJ"><i>Recent Advances in AI Planning: 4th European Conference on Planning, ECP'97, Toulouse, France, September 24–26, 1997, Proceedings</i></a>. Lecture Notes in Computer Science: Lecture Notes in Artificial Intelligence. Vol. 1348. Springer. pp. <span class="nowrap">273–</span>285. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-3-540-63912-1</bdi>.</cite> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170705062155/ftp://ftp.informatik.uni-freiburg.de/documents/papers/ki/dimopoulos-etal-ecp97.ps.gz">as Postscript</a></span>
</li>
<li id="cite_note-WhatIs-4"><span class="mw-cite-backlink">^ <a href="#cite_ref-WhatIs_4-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-WhatIs_4-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-WhatIs_4-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFLifschitz2008" class="citation journal cs1">Lifschitz, Vladimir (13 July 2008). <a rel="nofollow" class="external text" href="https://www.cs.utexas.edu/users/vl/papers/wiasp.pdf">"What is answer set programming?"</a> <span class="cs1-format">(PDF)</span>. <i>Proceedings of the 23rd National Conference on Artificial Intelligence</i>. <b>3</b>. AAAI Press: <span class="nowrap">1594–</span>1597.</cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text">
<cite id="CITEREFSubrahmanianZaniolo1995" class="citation book cs1">Subrahmanian, V.S.; Zaniolo, C. (1995). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=vpGEyZWP1dYC&pg=PA233">"Relating stable models and AI planning domains"</a>. In Sterling, Leon (ed.). <i>Logic Programming: Proceedings of the Twelfth International Conference on Logic Programming</i>. MIT Press. pp. <span class="nowrap">233–</span>247. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-262-69177-2</bdi>.</cite> <a rel="nofollow" class="external text" href="http://www.cs.ucla.edu/%7Ezaniolo/papers/iclp95.ps">as Postscript</a></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite id="CITEREFSoininenNiemelä1998" class="citation cs2">Soininen, T.; Niemelä, I. (1998), <a rel="nofollow" class="external text" href="http://www.tcs.hut.fi/~ini/papers/sn-faanmr98.ps.gz"><i>Formalizing configuration knowledge using rules with choices</i></a> <span class="cs1-format">(Postscript)</span>, Laboratory of Information Processing Science, Helsinki University of Technology</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text">
<cite id="CITEREFApt1999" class="citation book cs1">Marek, V.; Truszczyński, M. (20 May 1999). "Stable models and an alternative logic programming paradigm". In <a href="Krzysztof_R._Apt" title="Krzysztof R. Apt">Apt, Krzysztof R.</a> (ed.). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=GIhQAAAAMAAJ"><i>The Logic programming paradigm: a 25-year perspective</i></a> <span class="cs1-format">(PDF)</span>. Springer. pp. <span class="nowrap">169–</span>181. <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/cs/9809032">cs/9809032</a></span>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-3-540-65463-6</bdi>.</cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite id="CITEREFNiemelä1999" class="citation journal cs1">Niemelä, I. (November 1999). <a rel="nofollow" class="external text" href="http://users.ics.aalto.fi/ini/papers/lp-csp-long.ps.gz">"Logic programs with stable model semantics as a constraint programming paradigm"</a> <span class="cs1-format">(Postscript,gzipped)</span>. <i>Annals of Mathematics and Artificial Intelligence</i>. <b>25</b> (3/4): <span class="nowrap">241–</span>273. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1023%2FA%3A1018930122475">10.1023/A:1018930122475</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:14465318">14465318</a>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite id="CITEREFCrick2009" class="citation thesis cs1">Crick, Tom (2009). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160304035502/http://opus.bath.ac.uk/20352/1/UnivBath_PhD_2009_T_Crick.pdf"><i>Superoptimisation: Provably Optimal Code Generation using Answer Set Programming</i></a> <span class="cs1-format">(PDF)</span> (Ph.D.). University of Bath. Docket 20352. Archived from <a rel="nofollow" class="external text" href="http://opus.bath.ac.uk/20352/1/UnivBath_PhD_2009_T_Crick.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2016-03-04<span class="reference-accessdate">. Retrieved <span class="nowrap">2011-05-27</span></span>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite id="CITEREFRogelio_Davila" class="citation web cs1">Rogelio Davila. <a rel="nofollow" class="external text" href="http://www.rogeliodavila.com.mx/Programacion%20Logica/PL%20Notas/AnsProlog%20Overview.ppt">"AnsProlog, an overview"</a> <span class="cs1-format">(PowerPoint)</span>.</cite></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite id="CITEREFNiemeläSimonsSoinenen2000" class="citation book cs1">Niemelä, I.; Simons, P.; Soinenen, T. (2000). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=Abj-OpFeDjQC&pg=PA317">"Stable model semantics of weight constraint rules"</a>. In Gelfond, Michael; Leone, Nicole; Pfeifer, Gerald (eds.). <i>Logic Programming and Nonmonotonic Reasoning: 5th International Conference, LPNMR '99, El Paso, Texas, USA, December 2–4, 1999 Proceedings</i>. Lecture Notes in Computer Science: Lecture Notes in Artificial Intelligence. Vol. 1730. Springer. pp. <span class="nowrap">317–</span>331. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-3-540-66749-0</bdi>.</cite> <a rel="nofollow" class="external text" href="http://www.tcs.hut.fi/~ini/papers/nss-lpnmr99-www.ps.gz">as Postscript</a></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite id="CITEREFFerrarisLifschitz2005" class="citation journal cs1">Ferraris, P.; Lifschitz, V. (January 2005). "Weight constraints as nested expressions". <i>Theory and Practice of Logic Programming</i>. <b>5</b> (<span class="nowrap">1–</span>2): <span class="nowrap">45–</span>74. <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/cs/0312045">cs/0312045</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1017%2FS1471068403001923">10.1017/S1471068403001923</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:5051610">5051610</a>.</cite> <a rel="nofollow" class="external text" href="http://www.cs.utexas.edu/users/vl/papers/weight.ps">as Postscript</a></span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://archive.today/20150415155632/http://loqtek.com/?id=course_pars&sec=1">"Dependency parsing"</a>. Archived from <a rel="nofollow" class="external text" href="http://loqtek.com/?id=course_pars&sec=1">the original</a> on 2015-04-15<span class="reference-accessdate">. Retrieved <span class="nowrap">2015-04-15</span></span>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.mat.unical.it/aspcomp2013/files/ASP-CORE-2.03c.pdf">"ASP-Core-2 Input Language Specification"</a> <span class="cs1-format">(PDF)</span><span class="reference-accessdate">. Retrieved <span class="nowrap">14 May</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite id="CITEREFLefèvreBéatrixStéphanGarcia2017" class="citation journal cs1">Lefèvre, Claire; Béatrix, Christopher; Stéphan, Igor; Garcia, Laurent (May 2017). <a rel="nofollow" class="external text" href="https://www.cambridge.org/core/journals/theory-and-practice-of-logic-programming/article/abs/asperix-a-firstorder-forward-chaining-approach-for-answer-set-computing/2318F5D6647DF24A8F9A452F4C7B4D49">"ASPeRiX, a first-order forward chaining approach for answer set computing*"</a>. <i>Theory and Practice of Logic Programming</i>. <b>17</b> (3): <span class="nowrap">266–</span>310. <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1503.07717">1503.07717</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1017%2FS1471068416000569">10.1017/S1471068416000569</a>. <a href="ISSN_(identifier)" class="mw-redirect" title="ISSN (identifier)">ISSN</a> <a rel="nofollow" class="external text" href="https://search.worldcat.org/issn/1471-0684">1471-0684</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:2371655">2371655</a>.</cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text">
<cite id="CITEREFMarpleGupta2012" class="citation book cs1">Marple, Kyle.; Gupta, Gopal. (2012). "Galliwasp: A Goal-Directed Answer Set Solver". In Albert, Elvira (ed.). <i>Logic-Based Program Synthesis and Transformation, 22nd International Symposium, LOPSTR 2012, Leuven, Belgium, September 18-20, 2012, Revised Selected Papers</i>. Springer. pp. <span class="nowrap">122–</span>136.</cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><cite id="CITEREFAriasCarroSalazarMarple2018" class="citation journal cs1">Arias, J.; Carro, M.; Salazar, E.; Marple, K.; Gupta, G. (2018). <a rel="nofollow" class="external text" href="https://doi.org/10.1017%2FS1471068418000285">"Constraint Answer Set Programming without Grounding"</a>. <i>Theory and Practice of Logic Programming</i>. <b>18</b> (<span class="nowrap">3–</span>4): <span class="nowrap">337–</span>354. <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1804.11162">1804.11162</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1017%2FS1471068418000285">10.1017/S1471068418000285</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:13754645">13754645</a>.</cite></span>
</li>
<li id="cite_note-dlvsystem.com-18"><span class="mw-cite-backlink">^ <a href="#cite_ref-dlvsystem.com_18-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-dlvsystem.com_18-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.dlvsystem.com">"DLV System company page"</a>. DLVSYSTEM s.r.l<span class="reference-accessdate">. Retrieved <span class="nowrap">16 November</span> 2011</span>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="https://www.mat.unical.it/aspcomp2013/files/ASP-CORE-2.03c.pdf">ASP-Core-2 2.03c Input Language Specification</a></li>
<li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20080223132705/http://asparagus.cs.uni-potsdam.de/contest/">First ASP System Competition</a></li>
<li><a rel="nofollow" class="external text" href="http://www.cs.kuleuven.be/~dtai/events/ASP-competition/index.shtml">Second ASP Competition</a></li>
<li><a rel="nofollow" class="external text" href="http://www.mat.unical.it/aspcomp2011/">Third ASP Competition</a></li>
<li><a rel="nofollow" class="external text" href="http://www.mat.unical.it/aspcomp2013">Fourth ASP Competition</a></li>
<li><a rel="nofollow" class="external text" href="http://www.cs.uni-potsdam.de/platypus/">Platypus</a></li>
<li><a rel="nofollow" class="external text" href="http://www.kr.tuwien.ac.at/staff/tkren/deb.html">A variety of answer set solvers packaged for Debian / Ubuntu</a></li>
<li><a rel="nofollow" class="external text" href="http://www.cs.uni-potsdam.de/clasp/">Clasp Answer Set Solver</a></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Programming_paradigms_(Comparison_by_language)368" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div id="Programming_paradigms_(Comparison_by_language)368" style="font-size:114%;margin:0 4em"><a href="Programming_paradigm" title="Programming paradigm">Programming paradigms</a> (<a href="Comparison_of_multi-paradigm_programming_languages" title="Comparison of multi-paradigm programming languages">Comparison by language</a>)</div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Imperative_programming" title="Imperative programming">Imperative</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Structured_programming" title="Structured programming">Structured</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Jackson_structured_programming" title="Jackson structured programming">Jackson structures</a></li>
<li><a href="Block_(programming)" title="Block (programming)">Block-structured</a></li>
<li><a href="Modular_programming" title="Modular programming">Modular</a></li>
<li><a href="Non-structured_programming" title="Non-structured programming">Non-structured</a></li>
<li><a href="Procedural_programming" title="Procedural programming">Procedural</a></li>
<li><a href="Programming_in_the_large_and_programming_in_the_small" title="Programming in the large and programming in the small">Programming in the large and in the small</a></li>
<li><a href="Design_by_contract" title="Design by contract">Design by contract</a></li>
<li><a href="Invariant-based_programming" title="Invariant-based programming">Invariant-based</a></li>
<li><a href="Nested_function" title="Nested function">Nested function</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Object-oriented_programming" title="Object-oriented programming">Object-oriented</a><br>(<a href="Comparison_of_programming_languages_(object-oriented_programming)" title="Comparison of programming languages (object-oriented programming)">comparison</a>, <a href="List_of_object-oriented_programming_languages" title="List of object-oriented programming languages">list</a>)</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Class-based_programming" title="Class-based programming">Class-based</a>, <a href="Prototype-based_programming" title="Prototype-based programming">Prototype-based</a>, <a href="Object-based_language" title="Object-based language">Object-based</a></li>
<li><a href="Agent-oriented_programming" title="Agent-oriented programming">Agent</a></li>
<li><a href="Immutable_object" title="Immutable object">Immutable object</a></li>
<li><a href="Persistent_programming_language" title="Persistent programming language">Persistent</a></li>
<li><a href="Uniform_function_call_syntax" title="Uniform function call syntax">Uniform function call syntax</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Declarative_programming" title="Declarative programming">Declarative</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Functional_programming" title="Functional programming">Functional</a><br>(<a href="Comparison_of_functional_programming_languages" title="Comparison of functional programming languages">comparison</a>)</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Recursion_(computer_science)" title="Recursion (computer science)">Recursive</a></li>
<li><a href="Anonymous_function" title="Anonymous function">Anonymous function</a> (<a href="Partial_application" title="Partial application">Partial application</a>)</li>
<li><a href="Higher-order_programming" title="Higher-order programming">Higher-order</a></li>
<li><a href="Purely_functional_programming" title="Purely functional programming">Purely functional</a></li>
<li><a href="Total_functional_programming" title="Total functional programming">Total</a></li>
<li><a href="Strict_programming_language" title="Strict programming language">Strict</a></li>
<li><a href="Generalized_algebraic_data_type" title="Generalized algebraic data type">GADTs</a></li>
<li><a href="Dependent_type" title="Dependent type">Dependent types</a></li>
<li><a href="Functional_logic_programming" title="Functional logic programming">Functional logic</a></li>
<li><a href="Tacit_programming" title="Tacit programming">Point-free style</a></li>
<li><a href="Expression-oriented_programming_language" title="Expression-oriented programming language">Expression-oriented</a></li>
<li><a href="Applicative_programming_language" title="Applicative programming language">Applicative</a>, <a href="Concatenative_programming_language" title="Concatenative programming language">Concatenative</a></li>
<li><a href="Function-level_programming" title="Function-level programming">Function-level</a>, <a href="Value-level_programming" title="Value-level programming">Value-level</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Dataflow_programming" title="Dataflow programming">Dataflow</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Flow-based_programming" title="Flow-based programming">Flow-based</a></li>
<li><a href="Reactive_programming" title="Reactive programming">Reactive</a> (<a href="Functional_reactive_programming" title="Functional reactive programming">Functional reactive</a>)</li>
<li><a href="Signal_programming" class="mw-redirect" title="Signal programming">Signals</a></li>
<li><a href="Stream_processing" title="Stream processing">Streams</a></li>
<li><a href="Synchronous_programming_language" title="Synchronous programming language">Synchronous</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Logic_programming" title="Logic programming">Logic</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Abductive_logic_programming" title="Abductive logic programming">Abductive logic</a></li>
<li><a href="Constraint_programming" title="Constraint programming">Constraint</a> (<a href="Constraint_logic_programming" title="Constraint logic programming">Constraint logic</a>)</li>
<li><a href="Inductive_logic_programming" title="Inductive logic programming">Inductive logic</a></li>
<li><a href="Nondeterministic_programming" title="Nondeterministic programming">Nondeterministic</a></li>
<li><a href="Ontology_language" title="Ontology language">Ontology</a></li>
<li><a href="Probabilistic_logic_programming" title="Probabilistic logic programming">Probabilistic logic</a></li>
<li><a href="Query_language" title="Query language">Query</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Domain-specific_language" title="Domain-specific language">DSL</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Algebraic_modeling_language" title="Algebraic modeling language">Algebraic modeling</a></li>
<li><a href="Array_programming" title="Array programming">Array</a></li>
<li><a href="Automata-based_programming" title="Automata-based programming">Automata-based</a> (<a href="Action_language" title="Action language">Action</a>)</li>
<li><a href="Command_language" title="Command language">Command</a> (<a href="Spacecraft_command_language" title="Spacecraft command language">Spacecraft</a>)</li>
<li><a href="Differentiable_programming" title="Differentiable programming">Differentiable</a></li>
<li><a href="End-user_development" title="End-user development">End-user</a></li>
<li><a href="Grammar-oriented_programming" title="Grammar-oriented programming">Grammar-oriented</a></li>
<li><a href="Interface_description_language" title="Interface description language">Interface description</a></li>
<li><a href="Language-oriented_programming" title="Language-oriented programming">Language-oriented</a></li>
<li><a href="List_comprehension" title="List comprehension">List comprehension</a></li>
<li><a href="Low-code_development_platform" title="Low-code development platform">Low-code</a></li>
<li><a href="Modeling_language" title="Modeling language">Modeling</a></li>
<li><a href="Natural-language_programming" class="mw-redirect" title="Natural-language programming">Natural language</a></li>
<li><a href="Non-English-based_programming_languages" title="Non-English-based programming languages">Non-English-based</a></li>
<li><a href="Page_description_language" title="Page description language">Page description</a></li>
<li><a href="Pipeline_(software)" title="Pipeline (software)">Pipes</a> and <a href="Filter_(software)" title="Filter (software)">filters</a></li>
<li><a href="Probabilistic_programming" title="Probabilistic programming">Probabilistic</a></li>
<li><a href="Quantum_programming" title="Quantum programming">Quantum</a></li>
<li><a href="Scientific_programming_language" title="Scientific programming language">Scientific</a></li>
<li><a href="Scripting_language" title="Scripting language">Scripting</a></li>
<li><a href="Set_theoretic_programming" title="Set theoretic programming">Set-theoretic</a></li>
<li><a href="Simulation_language" title="Simulation language">Simulation</a></li>
<li><a href="Stack-oriented_programming" title="Stack-oriented programming">Stack-based</a></li>
<li><a href="System_programming_language" title="System programming language">System</a></li>
<li><a href="Tactile_programming_language" title="Tactile programming language">Tactile</a></li>
<li><a href="Template_processor" title="Template processor">Templating</a></li>
<li><a href="Transformation_language" title="Transformation language">Transformation</a> (<a href="Graph_rewriting" title="Graph rewriting">Graph rewriting</a>, <a href="Production_system_(computer_science)" title="Production system (computer science)">Production</a>, <a href="Pattern_matching" title="Pattern matching">Pattern</a>)</li>
<li><a href="Visual_programming_language" title="Visual programming language">Visual</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Concurrent_computing" title="Concurrent computing">Concurrent</a>,<br><a href="Distributed_computing" title="Distributed computing">distributed</a>,<br><a href="Parallel_computing" title="Parallel computing">parallel</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Actor_model" title="Actor model">Actor-based</a></li>
<li><a href="Automatic_mutual_exclusion" title="Automatic mutual exclusion">Automatic mutual exclusion</a></li>
<li><a href="Choreographic_programming" title="Choreographic programming">Choreographic programming</a></li>
<li><a href="Concurrent_logic_programming" title="Concurrent logic programming">Concurrent logic</a> (<a href="Concurrent_constraint_logic_programming" title="Concurrent constraint logic programming">Concurrent constraint logic</a>)</li>
<li><a href="Concurrent_object-oriented_programming" title="Concurrent object-oriented programming">Concurrent OO</a></li>
<li><a href="Macroprogramming" title="Macroprogramming">Macroprogramming</a></li>
<li><a href="Multitier_programming" title="Multitier programming">Multitier programming</a></li>
<li><a href="Organic_computing" title="Organic computing">Organic computing</a></li>
<li><a href="Parallel_programming_model" title="Parallel programming model">Parallel programming models</a></li>
<li><a href="Partitioned_global_address_space" title="Partitioned global address space">Partitioned global address space</a></li>
<li><a href="Process-oriented_programming" title="Process-oriented programming">Process-oriented</a></li>
<li><a href="Relativistic_programming" title="Relativistic programming">Relativistic programming</a></li>
<li><a href="Service-oriented_programming" title="Service-oriented programming">Service-oriented</a></li>
<li><a href="Structured_concurrency" title="Structured concurrency">Structured concurrency</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Metaprogramming" title="Metaprogramming">Metaprogramming</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Attribute-oriented_programming" title="Attribute-oriented programming">Attribute-oriented</a></li>
<li><a href="Automatic_programming" title="Automatic programming">Automatic</a> (<a href="Inductive_programming" title="Inductive programming">Inductive</a>)</li>
<li><a href="Dynamic_programming_language" title="Dynamic programming language">Dynamic</a></li>
<li><a href="Extensible_programming" title="Extensible programming">Extensible</a></li>
<li><a href="Generic_programming" title="Generic programming">Generic</a></li>
<li><a href="Homoiconicity" title="Homoiconicity">Homoiconicity</a></li>
<li><a href="Interactive_programming" title="Interactive programming">Interactive</a></li>
<li><a href="Macro_(computer_science)" title="Macro (computer science)">Macro</a> (<a href="Hygienic_macro" title="Hygienic macro">Hygienic</a>)</li>
<li><a href="Metalinguistic_abstraction" title="Metalinguistic abstraction">Metalinguistic abstraction</a></li>
<li><a href="Multi-stage_programming" title="Multi-stage programming">Multi-stage</a></li>
<li><a href="Program_synthesis" title="Program synthesis">Program synthesis</a> (<a href="Bayesian_program_synthesis" title="Bayesian program synthesis">Bayesian</a>, <a href="Inferential_programming" title="Inferential programming">Inferential</a>, <a href="Programming_by_demonstration" title="Programming by demonstration">by demonstration</a>, <a href="Programming_by_example" title="Programming by example">by example</a>)</li>
<li><a href="Reflective_programming" title="Reflective programming">Reflective</a></li>
<li><a href="Self-modifying_code" title="Self-modifying code">Self-modifying code</a></li>
<li><a href="Symbolic_programming" title="Symbolic programming">Symbolic</a></li>
<li><a href="Template_metaprogramming" title="Template metaprogramming">Template</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Separation_of_concerns" title="Separation of concerns">Separation<br>of concerns</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Aspect-oriented_programming" title="Aspect-oriented programming">Aspects</a></li>
<li><a href="Component-based_software_engineering" title="Component-based software engineering">Components</a></li>
<li><a href="Data-driven_programming" title="Data-driven programming">Data-driven</a></li>
<li><a href="Data-oriented_design" title="Data-oriented design">Data-oriented</a></li>
<li><a href="Event-driven_programming" title="Event-driven programming">Event-driven</a></li>
<li><a href="Feature-oriented_programming" title="Feature-oriented programming">Features</a></li>
<li><a href="Literate_programming" title="Literate programming">Literate</a></li>
<li><a href="Role-oriented_programming" title="Role-oriented programming">Roles</a></li>
<li><a href="Subject-oriented_programming" title="Subject-oriented programming">Subjects</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2024-05-08" href="https://en.wikipedia.org/wiki/?title=Answer_set_programming&oldid=1222937789">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>